package com.imedway.ihe.dtz.xds.vo;

import java.net.MalformedURLException;
import java.net.URL;

import javax.activation.DataHandler;
import javax.activation.FileDataSource;

public class RetrievedDocumentVO {

	private String mimeType;
	
	private String newDocumentUniqueId;
	
	private String newRepositoryUniqueId;
	
	private DataHandler dataHandler;

	public String getMimeType() {
		return mimeType;
	}

	public void setMimeType(String mimeType) {
		this.mimeType = mimeType;
	}

	public String getNewDocumentUniqueId() {
		return newDocumentUniqueId;
	}

	public void setNewDocumentUniqueId(String newDocumentUniqueId) {
		this.newDocumentUniqueId = newDocumentUniqueId;
	}

	public String getNewRepositoryUniqueId() {
		return newRepositoryUniqueId;
	}

	public void setNewRepositoryUniqueId(String newRepositoryUniqueId) {
		this.newRepositoryUniqueId = newRepositoryUniqueId;
	}

	public DataHandler getDataHandler() {
		return dataHandler;
	}

	public void setDataHandler(DataHandler dataHandler) {
		this.dataHandler = dataHandler;
	}
	
	public void setDataHandlerByFilePath(String fileString) {
        DataHandler dataHandler = null;
        try {
        	if(fileString.toLowerCase().startsWith("http")) {
                dataHandler = new DataHandler(new URL(fileString));
        	}else {
        		 dataHandler = new DataHandler(new FileDataSource(fileString));
        	}
        } catch (MalformedURLException e) {
        	 e.printStackTrace();      
        }
		this.dataHandler = dataHandler;
	}
	
}
